package com.tangruojie.stream;

import com.tangruojie.entity.Author;

import java.util.List;

/**
 * 终结操作之 count 统计
 */
public class StreamDemo10 {

    public static void main(String[] args) {

        List<Author> authors = StreamDemoTest.getAuthors();

        /**
         * 统计书籍的数目并去重
         */
        long count = authors.stream()
                .flatMap(author -> author.getBooks().stream())
                .distinct()
                .count();
        System.out.println(count);

    }

}
